function vmd_df_old(fbase, fnum)

%---------------------------------------------------------

% system size

jx=48; jy=1; jz=16; jv=256; jdir=2;

% physics paramters

vmax=10; Lx=450; Ly=450; 
kz=0.34; nz=1; vPhase=3.53235; u0=1.24; phi00=0.01;
SpeckleWidth = 99.91139;

% colormap bounds

fzvmax = 0.01;


%---------------------------------------------------------

  dv = 2*vmax/(jv-1);
  v  = (0:jv-1)*dv - vmax - vPhase;
  f0 = ( 1/sqrt(2*pi) )*exp( - 0.5*(v + vPhase).**2 );

  dz = 2*pi*nz/(jz*kz);
  z  = (0:jz-1)*dz;

  ixc = jx/2+1;
  iyc = min(jy/2+1, jy);


%---------------------------------------------------------
%-- reading density distribution

  fn = num2str(fnum,'%04d');

  fname = [fbase, '.dfu.', fn];

  fid = fopen(fname, 'rb');
  dfu = fread(fid, jv*jx*jy*jz*jdir, 'double');
  fclose(fid);

  dfu = reshape(dfu, jz, jv, jx, jdir);
  dfu = sum(dfu, 4);

  %f = reshape(sum(dfu,2), jz,jx); imagesc(f); return

  dfv = sum(sum( dfu, 3),1) / (jx*jz);

  dfv = reshape (dfv,jv,1);


  fname = [fbase, '.dfv.', fn, '.txt'];
  fid = fopen(fname, 'wt');
  fprintf(fid, '#1.v  2.df(v)\n');
  for i=1:jv 
     fprintf(fid, "%14.6e %14.6e\n", v(i), dfv(i) );
  end
  fclose(fid);

  figure(1, "Name", "averaged df(v)");
  plot(v, dfv, 'o-');
  xlabel("v");
  ylabel("df(v)")



end
